package com.swf.common.utils;

import java.io.*;
import java.util.Properties;

import javax.imageio.stream.*;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**  
 * 项目名称：SqlToHtml  
 * 类名称：PropertyUtils  
 * 类描述：  读取/properties/freemaker.properties中的配置信息
 * 创建人：Weifeng Shen
 * 创建时间：2012-12-27 下午2:40:52   
 * @version 1.0  
 */
public  class FwsPropertyUtils {
	private static final Logger logger = LoggerFactory.getLogger(FwsPropertyUtils.class);
	private static  Properties properties = new Properties();
	
	private FwsPropertyUtils(){
		
	}
	
	/**  
	 * method:getValue{根据key获取value}  
	 * @param key
	 * @return 属性文件中获取的value
	 */
	public static String getValue(String key){
		String value = "";
		 try {
			value=new String(properties.getProperty(key).getBytes("iso-8859-1"),"UTF-8");
		} catch (UnsupportedEncodingException e) {
			logger.error(e.getMessage());
		}
		 return value;
	}
	public static Properties getProperties() {
		return properties;
	}
	public static void setProperties(File file) {
		try {
			//加载配置文件
			InputStream is = new FileInputStream(file);
			properties.load(is);
		} catch (IOException e) {
			logger.error(e.getMessage());
		}
	}
	
	public static void setProperties(String path) {
		setProperties(FwsFileUtils.getFile(path));
	}
	
}
